# -*- mode: snippet -*-
# name: ggplot geom_bar template, proportional
# key: ggplot2.geom_bar.template
# key: geom_bar.template@ggplot2
# contributor: Shuguang Sun
# --
ggplot(${1:dt}, aes(x = ${2:as.factor(${3:x})}, y = ${4:y})) + # define x and y axis variables
  geom_bar(stat = "identity") +
  # the number of the point
  geom_bar(aes(fill = group), stat = "identity") +
  # the mean of all point (stack togather)
  geom_bar(aes(fill = group), stat = "summary", fun.y = "mean", position = "stack") +
  # dont stact
  geom_bar(aes(fill = group), stat = "summary", fun.y = "mean", position = "dodge") +
  # coord_flip() + # Rotate the box plot
  labs(x = "", y = "")
